package com.wsq.workmanager

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.work.OneTimeWorkRequestBuilder
import androidx.work.WorkManager
import androidx.work.WorkRequest
import com.wsq.workmanager.worker.MyWorker

/**
 * https://developer.android.google.cn/topic/libraries/architecture/workmanager/how-to/define-work
 */
class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        requestWork()
    }

    fun requestWork(){
        val myWorkerRequest: WorkRequest = OneTimeWorkRequestBuilder<MyWorker>().build()

        WorkManager.getInstance(MainActivity@this).enqueue(myWorkerRequest)
    }
}